﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using RMS.DataAccess.Entities;
using RMS.Utils.MVP;
using RMS.Web.Shell.Presenter;
using RMS.Web.Shell.View;
using RMS.Utils.Navigator;

namespace RMS
{
    public partial class RequestDetailsView : Page<RequestDetailsPresenter>, IRequestDetailsView
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    GetRequestData(Convert.ToInt32(Request.QueryString[0].ToString().Decrypt(Constants.ApplicationKey)));

                }
                catch (Exception)
                {
                    pnl.Visible = true;

                }


            }
        }
        private void GetRequestData(int RequestID)
        {
            var result = this.Presenter.CurrentRequest(RequestID);
            TXTPatientid.Text = result.PatientID.ToString();
            TXTFirstname.Text = result.FirstName;
            TXTFamilyname.Text = result.FamilyName;
            TXTRequestid.Text = result.RequestId.ToString();
            TXTRequestdate.Text = result.ReservationDate.ToString();
            TXTRequeststatues.Text = result.RequestStatues.ToString();
            TXTRadiologycode.Text = result.RadiologyCode;
            TXTReservationdate.Text = result.ReservationDate.ToString();
            TXTDevicename.Text = result.DeviceName;
            TXTDevicecode.Text = result.DeviceCode;
            TXTDescription.Text = result.Description;

        }

        protected void btnGetRequest_Click(object sender, EventArgs e)
        {
            GetRequestData(Convert.ToInt32(searchID.Text));
        }
    }
}